<template>
  <el-card>
    列表
    <el-table :data="tableData">
      <el-table-column label="昵称" width="150">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.nickName }}</span>
        </template>
      </el-table-column>
      <el-table-column label="姓名" width="150">
        <template slot-scope="scope">
          <el-popover trigger="hover" placement="top">
            <p>姓名: {{ scope.row.name }}</p>
            <p>住址: {{ scope.row.address }}</p>
            <div slot="reference" class="name-wrapper">
              <el-tag size="medium">{{ scope.row.name }}</el-tag>
            </div>
            <p>邮箱: {{ scope.row.email }}</p>
            <p>性别: {{ scope.row.isMale }}</p>
            <p>昵称: {{ scope.row.nickName }}</p>
            <p>手机号: {{ scope.row.phone }}</p>
            <p>头像：</p>
          </el-popover>
        </template>
      </el-table-column>
      <el-table-column label="电话" width="150">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.phone }}</span>
        </template>
      </el-table-column>
      <el-table-column label="地址" width="350">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.address }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="mini" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
          <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </el-card>
</template>

<script>
import { getList } from '../../api/getData'
export default {
  name: 'list2_list.vue',
  data() {
    return {
      tableData: [
        // {
        //   date: '2016-05-02',
        //   name: '王小虎',
        //   address: '上海市普陀区金沙江路 1518 弄'
        // }, {
        //   date: '2016-05-04',
        //   name: '王小虎',
        //   address: '上海市普陀区金沙江路 1517 弄'
        // }, {
        //   date: '2016-05-01',
        //   name: '王小虎',
        //   address: '上海市普陀区金沙江路 1519 弄'
        // }, {
        //   date: '2016-05-03',
        //   name: '王小虎',
        //   address: '上海市普陀区金沙江路 1516 弄'
        // }
      ]
    }
  },
  mounted() {
    this.getMockList()
  },
  methods: {
    handleEdit(index, row) {
      console.log(index, row)
    },
    handleDelete(index, row) {
      console.log(index, row)
    },

    async getMockList() {
      try {
        const result = await getList()
        console.log('返回成功', result)
        // eslint-disable-next-line eqeqeq
        if (result.data.code == 0) {
          this.tableData = result.data.data.data
        }
        // console.log(result.data.data.data);
      } catch (error) {
        console.log(error)
      }
    }
  }

}
</script>

<style>
</style>
